package com.esunny.resourcevisualization.util;


import com.esunny.resourcevisualization.domain.entity.User;
import org.springframework.stereotype.Component;

/**
 * @author ：李先生
 * @date ：Created in 2020/7/18 16:31
 * @description： 自定义ThreadLocal用于保存用户信息, 用于代替session
 * @modified By：
 * @version: $
 */
@Component
public class HostHolder {
    private ThreadLocal<User> users = new ThreadLocal<>();

    public void setUser(User user) {
        users.set(user);
    }

    public User getUser() {
        return users.get();
    }

    public void clear() {
        users.remove();
    }
}
